package com.boot.sample.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@SpringBootApplication
public class BootApplication implements InitializingBean {
    private static final Logger logger = LoggerFactory.getLogger(BootApplication.class);
    public static void main(String[] args) {

        SpringApplication.run(BootApplication.class, args);
    }
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    HashOperations hashOperations;

    @RequestMapping("/")
    String index() {
        redisTemplate.delete("test_for_boot");
        return "ok";
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        hashOperations = redisTemplate.opsForHash();
    }
}
